<?php
/**
 * Created by PhpStorm.
 * User: haobin
 * Date: 2016/9/23
 * Time: 10:28
 */
require_once('conn.php');
require_once('functions.php');
$uid = $_GET['id'];
//$userdataArr = $mysql->query("select * from `user` WHERE `id` = {$uid}");
//$userdata = $userdataArr[0];
//好友数目
$studentNumSql = "select count(*) as num from `USER` WHERE `pid` = {$uid} AND `login` = 1";
$studentNumArr = $mysql->query($studentNumSql);
$studentNum = $studentNumArr[0]['num'];
//好友贡献排行
//$studentScoreSql = "select sid,sum(score) as score from `score_detail` WHERE `uid`={$uid} AND `type` = 0 AND `sid` <> 0  GROUP BY sid ORDER BY sum(score) desc limit 50";
$studentScoreSql = "select `id`,`contribution` from `user` WHERE `pid`={$uid} AND `login` = 1 ORDER BY `contribution` DESC limit 50";
$studentScoreArr = $mysql->query($studentScoreSql);
?>
<html>
<head>
    <meta charset="UTF-8">
    <title>微有趣</title>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="./assets/css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="./assets/css/pupil.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script>
        function changeSize() {
            var propo = $(window).width() / 640;
            $('html').css('font-size', 40 * propo + 'px');
        };
        changeSize();
        $(window).resize(function() {
            changeSize();
        });
    </script>
</head>
<body>
<div class="wrap">
    <header class="clearfix">
        <div class="left">
            好友贡献榜
        </div>
        <div class="right clearfix">
            <span class="num"><?= $studentNum?></span><i></i>
        </div>
    </header>
    <div class="con">
    	<div style="text-align: left;font-size: .7rem;">
    		关于好友数减少，系统展示的好友的个数为已登录App的真正好友，苹果手机注册以及未登录App的好友未显示在内，如下次有登录激活会重新记录增加。
    	</div>
        <div class="nav">
            <span>前50名</span><span>头像</span><span>好友ID</span><span>贡献积分</span>
        </div>
        <ul class="list">
            <?php
            $i = 0;
            foreach($studentScoreArr as $student):
                $studentid = $student['id'];
                $studentInfoArr = $mysql->query("select * from `user` WHERE  id = {$studentid}");
                $studentHead = $studentInfoArr[0]['head'];
                ?>
            <li>
                <span class="one"><?= ++$i;?></span>
                <span style="background-image:url(<?= $studentHead?>);" class="two"></span>
                <span class="three"><?= $studentid?></span>
                <span class="four"><?= $student['contribution']?></span>
            </li>
            <?php endforeach;?>
        </ul>
    </div>
</div>
</body>
</html>

